package expandingproject;

import java.util.Scanner;
import static expandingproject.ExpandingProject.scrambleOffset;

/**
 *
 * @author Inderpreet
 */
public class StringManipulator {

    public String getUserString(String userOption) {
        Scanner keyb = new Scanner(System.in);
        if (userOption.equalsIgnoreCase("E")) {
            System.out.println("Please enter the String to Encrypt:");
            String userInput = keyb.nextLine();
            return userInput;
        } else if (userOption.equalsIgnoreCase("D")) {
            System.out.println("Please enter the String to Decrypt:");
            String userInput = keyb.nextLine();
            return userInput;
        }
        return null;
    }

    public void stringManipulator(String userInput, String userOption) {
        if (userOption.equalsIgnoreCase("E")) {
            for (char s : userInput.toCharArray()) {
                s -= scrambleOffset;
                System.out.print(s);
            }
        } else if (userOption.equalsIgnoreCase("D")) {
            for (char s : userInput.toCharArray()) {
                s += scrambleOffset;
                System.out.print(s);
            }
        }
        System.out.println("");
    }

    public String getUserOption() {
        Scanner keyb = new Scanner(System.in);
        System.out.println("Would you like to (E)ncrypt, (D)ecrypt or (Q)uit?");
        String userOption = keyb.nextLine();
        return userOption;
    }
}
